home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 11
/
FM Towns Free Software Collection 11.iso
/
t_os
/
shell
/
ghel
/
src
/
parts.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-08-04
|
5KB
|
386 lines
/*
GHEL v1.2 [呼び出し関数、他]
Programmed by Keijiro Takahashi (novice)
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <msdos.cf>
#include <time.h>
#include <winb.h>
#include <te.h>
#include <fntb.h>
#include <gui.h>
#include <egb.h>
#include <wgb.h>
#include <file_dlg.h>
#include <guidbg.h>
#include "type.h"
#include "hel.h"
char *filedlg();
void alert(char *altmsg);
int prevhel(hel *buf);
int revhel(hel *buf);
int dsphel(hel *buf);
extern char *guiEgbPtr;
hel helbuf;
int helstatus = NODATA;
int helwait = 0;
int alertDlg = -1 ;
int alertMsg = -1 ;
int alertExecBtn = -1 ;
int backHyper1 = -1 ;
int baseWin = -1 ;
int cntrlDlg = -1 ;
int playBtn = -1 ;
int fileBtn = -1 ;
int cntrlBar = -1 ;
int pageMsg = -1 ;
int waitNumbox = -1 ;
int helWin = -1 ;
int backHyper2 = -1 ;
char pageStr[10]=" 0/0 ";
int shell(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
int ret=ILLEGAL_FUNCTION;
switch (messId)
{
case GM_QUIT:
MMI_SetHaltFlag(TRUE);
ret = NOERR;
break;
case GM_WAKE:
MMI_SendMessage(baseWin,MM_WAKE,0);
ret = NOERR;
break;
case GM_SLEEP:
MMI_SendMessage(baseWin,MM_SLEEP,0);
ret = NOERR;
break;
}
return(ret);
}
int alertFunc(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
MMI_SetHaltFlag(TRUE);
return NOERR ;
}
int baseWinFunc(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
if (messId==MM_ERASE)
{
MMI_SetHaltFlag(TRUE);
}
return(ILLEGAL_FUNCTION);
}
int BtnFunc(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
if (kobj==fileBtn)
{
helstatus = STOP;
if ( filedlg(helbuf.pathname) != NULL )
{
if(loadhel(helbuf.pathname,&helbuf)==0)
{
helcnv(&helbuf);
dsphel(&helbuf);
helstatus=STOP;
}
}
}
else if (kobj==playBtn)
{
helstatus = (helstatus==PLAY) ? STOP : PLAY;
}
return(NOERR);
}
int cntrlBarFunc(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
int dum;
MMI_SendMessage(cntrlBar,MM_GETSCROLL,5,&(helbuf.page)
,&dum,&dum,&dum,&dum);
dsphel(&helbuf);
return NOERR ;
}
int helWinFunc(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
if (messId==MM_SHOW)
{
if (helbuf.buf!=NULL)
{
PBC_para para;
para.slct = getds();
para.x1 = 0;
para.y1 = 0;
para.x2 = 159;
para.y2 = 119;
para.adr = helbuf.buf+helbuf.page*2400;
EGB_color(guiEgbPtr,0,MG_colorChange(15));
EGB_color(guiEgbPtr,1,MG_colorChange(8));
EGB_writeMode(guiEgbPtr,9);
WGB_putBlockColor(guiEgbPtr,1,(char *)¶);
}
}
return(ILLEGAL_FUNCTION);
}
int waitNumboxFunc(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
int dum;
MMI_SendMessage(waitNumbox,MM_GETNUMBOX,5,&helwait,&dum,&dum,&dum,&dum);
return NOERR ;
}
/*
以下、呼び出し関数以外の下請け関数
*/
/*
Idle Task
*/
void idleTask()
{
static clock_t count_st=0;
if (helstatus==PLAY)
{
if ( (clock()-count_st) > helwait )
{
count_st=clock();
prevhel(&helbuf);
}
}
return;
}
/*
display
*/
int dsphel(hel *buf)
{
sprintf(pageStr,"%4d/%-4d",buf->page_max,buf->page);
MMI_SendMessage(pageMsg,MM_SHOW,0);
MMI_SendMessage(pageMsg,MM_SHOW,0);
MMI_SendMessage(cntrlBar,MM_SETSCROLL,5,buf->page,0,buf->page_max,1,0);
MMI_SendMessage(cntrlBar,MM_SHOW,0);
MMI_SendMessage(helWin,MM_SHOW,0);
return(NOERR);
}
/*
preview
*/
int prevhel(hel *buf)
{
if(++buf->page>buf->page_max)
{
buf->page=0;
}
dsphel(&helbuf);
return(NOERR);
}
/*
review
*/
int revhel(hel *buf)
{
if(--buf->page<0)
{
buf->page=buf->page_max;
}
dsphel(&helbuf);
return(NOERR);
}
/*
ファイルダイヤログ
*/
char *filedlg(char *pathname)
{
static char *wildcard[] = {"*.hel",NULL};
unsigned int dum1;
int ret,dum2;
FDG_SetTitle("読 込","読 込","取 消");
ret = FDG_DspFileDlg( backHyper2,
FDG_ALERT | FDG_SLCTCHK | FDG_FILEONLY,
NULL,wildcard,&dum1 );
if (ret)
{
FDG_GetPathName(pathname,&dum2,0);
}
else
{
return(NULL);
}
return(pathname);
}
/*
アラート
*/
void alert(char *altmsg)
{
MMI_SendMessage(alertMsg,MM_SETMSG,1,altmsg);
MMI_SendMessage(alertDlg,MM_ATTACH,1,backHyper2);
MMI_SendMessage(alertDlg,MM_SHOW,0);
MMI_ExecSystem();
MMI_SendMessage(alertDlg,MM_ERASE,0);
MMI_SendMessage(alertDlg,MM_DETACH,0);
return;
}